package com.ruoyi.system.Control;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;

import java.util.List;
import java.util.Map;

public class JsonToListExample {
    public static void main(String[] args) throws Exception {
        String json = "[{\"name\":\"Alice\", \"age\":25}, {\"name\":\"Bob\", \"age\":30}]";

        ObjectMapper objectMapper = new ObjectMapper();
        TypeReference<List<Map<String, Integer>>> typeRef = new TypeReference<List<Map<String, Integer>>>() {};
        List<Map<String, Integer>> list = objectMapper.readValue(json, typeRef);

        for (Map<String, Integer> map : list) {
            System.out.println("Name: " + map.get("name") + ", Age: " + map.get("age"));
        }
    }
}